//
//  NSObject+ExRunTime.m
//  OC-Example
//
//  Created by iOS_Doule on 2019/8/1.
//  Copyright © 2019 apang.men. All rights reserved.
//

#import "NSObject+ExRunTime.h"
#import <objc/runtime.h>
@implementation NSObject (ExRunTime)
+ (void)printAllMethod {
    unsigned int count;
    Class cls = [self class];
    Method *methdList = class_copyMethodList(cls, &count);
    printf("className:%s  methodList:\n",NSStringFromClass(cls).UTF8String);
    for (int i = 0; i < count; i++) {
        Method methodSelector= methdList[i];
        NSString *methodName = NSStringFromSelector(method_getName(methodSelector));
        printf("%s\n",methodName.UTF8String);
    }
    free(methdList);
}

+ (void)instanceMethodExchange:(SEL)method originMethod:(SEL)originMethod {
    method_exchangeImplementations(class_getInstanceMethod(self.class, originMethod), class_getInstanceMethod(self.class, method));
}
@end
